/* RankerInspector.m
 * Written By:  Thomas Burkholder
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */

#import "RankerInspector.h"
#import "CellSelector.h"
#import "CellCategories.h"

@implementation Ranker (AttributesInspector)

- (const char *)getInspectorClassName
{
	NXEvent *ev;

	ev = [NXApp currentEvent];
	if (ev->flags&NX_ALTERNATEMASK) // the superclass's inspector
		return [super getInspectorClassName];
	else // the real inspector
		return "RankerInspector";
}

- finishUnarchiving
{
	if (!protoCell) {
		id p, pc;

		pc = [CellSelector 
					getCellClassRespondsTo:@selector(makePrototype)];
		if ([pc respondsTo:@selector(defaultMatrixMode)])
			[self setMode:[pc defaultMatrixMode]];
		else
			[self setMode:NX_TRACKMODE];

		if ([pc respondsTo:@selector(makePrototype)])
			p = [pc makePrototype];
		else {
			p = [[pc alloc] init];
		}
		[self setPrototype:p];
		[self addRow];
		[self addRow];
		[self addRow];
		[self sizeToCells];
		[[NXApp selectionOwner] redrawSelection];
	}
	return self;	
}

@end

@implementation RankerInspector

- init
{
	char buf[MAXPATHLEN + 1];
	id bundle;
	[super init];
	bundle = [NXBundle bundleForClass:[Ranker class]];
	[bundle getPath:buf forResource:"RankerInspector" ofType:"nib"];
	[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
	return self;
}

- ok:sender
{
	[object setRankMode:[rankSwitch state]];
	return [super ok:sender];
}

- revert:sender
{
	[rankSwitch setState:[object rankMode]];
	return [super revert:sender];
}

- (BOOL)wantsButtons
{
	return NO;
}

@end
